<script setup lang="ts">
import type {CategoryItem} from '@/types/home'
  interface props {
    list: CategoryItem[]
  }
  const prop = defineProps<props>()
  const goToCategory = (index: number)=> {
    if(index === 9){
      // 超出分类范围，归0（兼容处理）
      index = 0
    }
    wx.setStorageSync('curIndex', index)
    uni.switchTab({
      url: '/pages/category/category',
    });
  }
</script>

<template>
  <view class="category">
    <view class="category-item" v-for="(item, index) in list" :key="item.id">
    <image
      class="icon"
      :src="item.icon"
      @tap="goToCategory(index)"
    ></image>
      <text class="text">{{item.name}}</text>
  </view>
  </view>
</template>

<style lang="scss">
@import '@/pages/index/components/styles/CategoryPanel.scss';
</style>